<?php

class Email
{
	/**
	*@var string 
	**/
	private $email;
	/**
	*@var string const regex
	**/
	const Email_regex = '/^[\w]+(\.[\w]+)*@([\w]+\.)+[a-z]{2,7}$/';


	/**
	*@param string 
	**/
	public function __construct($email)
	{
		if($this->validEmail($email))
		{
			$this->email = $email;  
		}

	}

	/**
	*@return string 
	**/
	public function getEmail()
	{
		return $this->email;
	}

	/**
	*@param string 
	*@return bool 
	**/
	private function validEmail($email)
	{
		$pattern = self::Email_regex;
		preg_match($pattern, $email, $matches);

		if(empty($matches))
		{
			throw new Exception("Ett fel uppstod i skapande av email");
		}
		return true;
	}
}